﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Asset_Manager
{  
    public partial class frmLogin : Form
    {
        bool isValid = false;
        public frmLogin(ServiceReference1.User user)
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            // Set cursor as hourglass
            Cursor.Current = Cursors.WaitCursor;            
            ServiceReference1.Service1Client lg = new ServiceReference1.Service1Client();
            frmMDIMain._user = lg.Login(txtUserName.Text, txtPassword.Text);

            if (frmMDIMain._user != null) 
            {
                isValid = true;
            }

            if (isValid != true)
            {
                Application.Exit();
            }
            else
            {
                this.Close();
            }
            Cursor.Current = Cursors.Default;
            this.Close();
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            string UN, PW;
            //TODO INPUT SANITATION AND VERIFICATION 
            UN = txtUserName.Text.ToString();
            PW = txtPassword.Text.ToString();

            ServiceReference1.Service1Client lg = new ServiceReference1.Service1Client();         
        }
    }
}
